home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Windows files / Q3WinSDK.exe / QD3DSDK / Interfaces / QD3DRenderer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-20  |  44.0 KB  |  1,309 lines

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DRenderer.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Renderer types and routines                                   **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1996 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #ifndef QD3DRenderer_h
  15. #define QD3DRenderer_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #include "QD3DView.h"
  22. #include "QD3DSet.h"
  23.  
  24. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH 
  25.  
  26. /*
  27.  * the following gets around a problem in xlc with unsigned 32 bit enums 
  28.  * that have been defined in system header files
  29.  */
  30. #if defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  31.     #pragma options enum=small
  32. #endif
  33.  
  34. #include <Events.h>
  35.  
  36. /*
  37.  * reset to default after the system headers
  38.  */
  39. #if defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  40.     #pragma options enum=reset
  41. #endif
  42.  
  43. #endif /* WINDOW_SYSTEM_MACINTOSH */
  44.  
  45. #if defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  46.     #include "windows.h"
  47. #endif /* WINDOW_SYSTEM_WIN32 */
  48.  
  49. #if defined(THINK_C) || defined(__SC__)
  50.     #pragma options(!pack_enums, !align_arrays)
  51.     #pragma SC options align=power
  52. #elif defined(__MWERKS__)
  53.     #pragma enumsalwaysint on
  54.     #pragma align_array_members off
  55.     #pragma options align=native
  56. #elif defined(__PPCC__)
  57.     #pragma options align=power
  58. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  59.     #pragma options enum=int
  60. #endif
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif    /* __cplusplus */
  65.  
  66. /******************************************************************************
  67.  **                                                                             **
  68.  **                            User Interface Things                             **
  69.  **                                                                             **
  70.  *****************************************************************************/
  71.  
  72. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  73.  
  74. /*
  75.  *  A callback to an application's event handling code. This is needed to    
  76.  *  support movable modal dialogs. The dialog's event filter calls this      
  77.  *  callback with events it does not handle.                                 
  78.  *  If an application handles the event it should return kQ3True.            
  79.  *  If the application does not handle the event it must return kQ3False and 
  80.  *  the dialog's event filter will pass the event to the system unhandled.   
  81.  */
  82. typedef TQ3Boolean (QD3D_CALLBACK *TQ3MacOSDialogEventHandler)( 
  83.     EventRecord     event);
  84.  
  85. typedef struct TQ3DialogAnchor {
  86.     TQ3MacOSDialogEventHandler clientEventHandler;
  87. } TQ3DialogAnchor;
  88.  
  89. #elif defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  90.  
  91. typedef struct TQ3DialogAnchor {
  92.     HWND    ownerWindow;    
  93. } TQ3DialogAnchor;
  94.  
  95. #else  /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  96.  
  97. typedef struct TQ3DialogAnchor {
  98.     void    notUsed;  /* place holder */
  99. } TQ3DialogAnchor;
  100.  
  101. #endif  /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  102.  
  103.  
  104. /******************************************************************************
  105.  **                                                                             **
  106.  **                                Renderer Functions                             **
  107.  **                                                                             **
  108.  *****************************************************************************/
  109.  
  110. QD3D_EXPORT TQ3RendererObject QD3D_CALL Q3Renderer_NewFromType(
  111.     TQ3ObjectType            rendererObjectType);
  112.  
  113. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3Renderer_GetType(
  114.     TQ3RendererObject        renderer);
  115.  
  116. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  117.  
  118. /*
  119.  *    Non-blocking, flush all buffered graphics to rasterizer. May or
  120.  *    may not update the draw context.
  121.  *    
  122.  *    This function has been replaced by Q3View_Flush
  123.  */
  124. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_Flush(
  125.     TQ3RendererObject        renderer,
  126.     TQ3ViewObject            view);
  127.     
  128. /*
  129.  *    Blocking, flush all buffered graphics to rasterizer and update
  130.  *    draw context.
  131.  *    
  132.  *    This function has been replaced by Q3View_Sync
  133.  */
  134. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_Sync(
  135.     TQ3RendererObject        renderer,
  136.     TQ3ViewObject            view);
  137.     
  138. #endif  /*  QD3D_OBSOLETE  */
  139.  
  140. /*
  141.  *    Q3Renderer_HasModalConfigure
  142.  *        Determine if this renderer has a modal settings dialog.
  143.  *
  144.  *    Q3Renderer_ModalConfigure
  145.  *        Have the renderer pop up a modal dialog box to configure its settings.
  146.  *    dialogAnchor - is platform specific data passed by the client to support
  147.  *      movable modal dialogs. 
  148.  *    MacOS: this is a callback to the calling application's event handler.
  149.  *      The renderer calls this function with events not handled by the 
  150.  *      settings dialog. This is necessary in order to support movable modal 
  151.  *      dialogs. An application's event handler must return kQ3True if it 
  152.  *      handles the event passed to the callback or kQ3False if not. 
  153.  *      An application which doesn't want to support a movable modal configure
  154.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  155.  *    Win32: this is the HWND of the owning window (typically an application's
  156.  *      main window).
  157.  *  canceled - returns a boolean inditacating that the user canceled the 
  158.  *    dialog.
  159.  *      
  160.  */
  161. QD3D_EXPORT TQ3Boolean QD3D_CALL Q3Renderer_HasModalConfigure(
  162.     TQ3RendererObject        renderer);
  163.  
  164. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_ModalConfigure(
  165.     TQ3RendererObject        renderer, 
  166.     TQ3DialogAnchor         dialogAnchor, 
  167.     TQ3Boolean                *canceled);
  168.  
  169. /*
  170.  *    Q3Renderer_GetConfigurationData
  171.  *        Allows an application to collect private renderer configuration data
  172.  *      which it will then save. For example in a preference file or in a 
  173.  *        style template. An application should tag this data with the 
  174.  *        Renderer's object  name.
  175.  *    
  176.  *        if dataBuffer is NULL actualDataSize returns the required size in 
  177.  *        bytes of a data buffer large enough to store private data. 
  178.  *
  179.  *      bufferSize is the actual size of the memory block pointed to by 
  180.  *        dataBuffer
  181.  *
  182.  *        actualDataSize - on return the actual number of bytes written to the 
  183.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  184.  * 
  185.  */
  186. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_GetConfigurationData(
  187.     TQ3RendererObject        renderer, 
  188.     unsigned char            *dataBuffer, 
  189.     unsigned long            bufferSize,
  190.     unsigned long            *actualDataSize);
  191.  
  192. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_SetConfigurationData(
  193.     TQ3RendererObject        renderer, 
  194.     unsigned char            *dataBuffer, 
  195.     unsigned long            bufferSize);
  196.  
  197.  
  198. /******************************************************************************
  199.  **                                                                             **
  200.  **                        Interactive Renderer Specific Functions                 **
  201.  **                                                                             **
  202.  *****************************************************************************/
  203.  
  204. /* 
  205.  *  CSG IDs attribute 
  206.  */
  207. #define kQ3AttributeTypeConstructiveSolidGeometryID \
  208.     Q3_OBJECT_TYPE('c','s','g','i')
  209.  
  210. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  211.  
  212. #define kQ3AttributeType_ConstructiveSolidGeometryID \
  213.     kQ3AttributeTypeConstructiveSolidGeometryID
  214.     
  215. #endif  /*  QD3D_OBSOLETE  */
  216.  
  217. /* 
  218.  *  Object IDs, to be applied as attributes on geometries 
  219.  */
  220. #define kQ3SolidGeometryObjNone    -1
  221. #define kQ3SolidGeometryObjA     0
  222. #define kQ3SolidGeometryObjB     1
  223. #define kQ3SolidGeometryObjC     2
  224. #define kQ3SolidGeometryObjD     3
  225. #define kQ3SolidGeometryObjE     4
  226.  
  227. /* 
  228.  *  Possible CSG equations 
  229.  */
  230. typedef enum TQ3CSGEquation {
  231.     kQ3CSGEquationAandB            = (int)0x88888888,
  232.     kQ3CSGEquationAandnotB         = 0x22222222,
  233.     kQ3CSGEquationAanBonCad        = 0x2F222F22,
  234.     kQ3CSGEquationnotAandB        = 0x44444444,
  235.     kQ3CSGEquationnAaBorCanB    = 0x74747474
  236. } TQ3CSGEquation;
  237.  
  238. typedef enum TQ3HiddenSurfaceRemovalMode {
  239.     kQ3HiddenSurfaceRemovalMode_None,
  240.     kQ3HiddenSurfaceRemovalMode_Shallow,
  241.     kQ3HiddenSurfaceRemovalMode_Deep
  242. } TQ3HiddenSurfaceRemovalMode;
  243.  
  244. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetCSGEquation(
  245.     TQ3RendererObject        renderer,
  246.     TQ3CSGEquation            equation);
  247.  
  248. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetCSGEquation(
  249.     TQ3RendererObject        renderer,
  250.     TQ3CSGEquation            *equation);
  251.  
  252. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetPreferences(
  253.     TQ3RendererObject        renderer,
  254.     long                    vendorID,
  255.     long                    engineID);
  256.  
  257. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetPreferences(
  258.     TQ3RendererObject        renderer,
  259.     long                    *vendorID,
  260.     long                    *engineID);
  261.     
  262. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetDoubleBufferBypass(
  263.     TQ3RendererObject        renderer,
  264.     TQ3Boolean                bypass);
  265.  
  266. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetDoubleBufferBypass(
  267.     TQ3RendererObject        renderer,
  268.     TQ3Boolean                *bypass);
  269.  
  270. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetRAVEContextHints(
  271.     TQ3RendererObject        renderer,
  272.     unsigned long            RAVEContextHints);
  273.  
  274. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetRAVEContextHints(
  275.     TQ3RendererObject        renderer,
  276.     unsigned long            *RAVEContextHints);
  277.  
  278. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetRAVETextureFilter(
  279.     TQ3RendererObject        renderer,
  280.     unsigned long            RAVEtextureFilterValue);
  281.  
  282. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetRAVETextureFilter(
  283.     TQ3RendererObject        renderer,
  284.     unsigned long            *RAVEtextureFilterValue);
  285.  
  286.  
  287. /******************************************************************************
  288.  **                                                                             **
  289.  **                            Renderer View Tools                                 **
  290.  **                                                                             **
  291.  **                    You may only call these methods from a plug-in             **
  292.  **                                                                             **
  293.  *****************************************************************************/
  294.  
  295. /*
  296.  *    Call by a renderer to call the user "idle" method, with progress 
  297.  *    information.
  298.  *    
  299.  *    Pass in (view, 0, n) on first call
  300.  *    Pass in (view, 1..n-1, n) during rendering
  301.  *    Pass in (view, n, n) upon completion
  302.  *    
  303.  *    Note: The user must have supplied an idleProgress method with 
  304.  *    Q3XView_SetIdleProgressMethod. Otherwise, the generic idle method is
  305.  *    called with no progress data. e.g. the Q3View_SetIdleMethod method
  306.  *    is called instead. (current and final are ignored, essentially.)
  307.  *
  308.  *    Returns kQ3Failure if rendering is cancelled.
  309.  */
  310. QD3D_EXPORT TQ3Status QD3D_CALL Q3XView_IdleProgress(
  311.      TQ3ViewObject        view,
  312.      unsigned long        current,
  313.      unsigned long        completed);
  314.  
  315. /*
  316.  *    Called by an asynchronous renderer when it completes a frame.
  317.  */
  318. QD3D_EXPORT TQ3Status QD3D_CALL Q3XView_EndFrame(
  319.      TQ3ViewObject        view);
  320.  
  321.  
  322. /******************************************************************************
  323.  **                                                                             **
  324.  **                            Renderer AttributeSet Tools                         **
  325.  **                                                                             **
  326.  **                    You may only call these methods from a plug-in             **
  327.  **                                                                             **
  328.  *****************************************************************************/
  329.  
  330. /*
  331.  *    Faster access to geometry attribute sets.
  332.  *    
  333.  *    Returns pointer to INTERNAL data structure for elements and attributes
  334.  *    in an attributeSet, or NULL if no attribute exists.
  335.  *    
  336.  *    For attributes of type kQ3AttributeType..., the internal data structure
  337.  *    is identical to the data structure used in Q3AttributeSet_Add.
  338.  */
  339. QD3D_EXPORT void *QD3D_CALL Q3XAttributeSet_GetPointer(
  340.      TQ3AttributeSet            attributeSet,
  341.      TQ3AttributeType        attributeType);
  342.      
  343. #define kQ3XAttributeMaskNone                        \
  344.     0L
  345.  
  346. #define kQ3XAttributeMaskSurfaceUV                    \
  347.     (1 << (kQ3AttributeTypeSurfaceUV - 1))
  348.  
  349. #define kQ3XAttributeMaskShadingUV                    \
  350.     (1 << (kQ3AttributeTypeShadingUV - 1))
  351.  
  352. #define kQ3XAttributeMaskNormal                        \
  353.     (1 << (kQ3AttributeTypeNormal - 1))
  354.  
  355. #define kQ3XAttributeMaskAmbientCoefficient            \
  356.     (1 << (kQ3AttributeTypeAmbientCoefficient - 1))
  357.  
  358. #define kQ3XAttributeMaskDiffuseColor                \
  359.     (1 << (kQ3AttributeTypeDiffuseColor - 1))
  360.  
  361. #define kQ3XAttributeMaskSpecularColor                \
  362.     (1 << (kQ3AttributeTypeSpecularColor - 1))
  363.  
  364. #define kQ3XAttributeMaskSpecularControl            \
  365.     (1 << (kQ3AttributeTypeSpecularControl - 1))
  366.  
  367. #define kQ3XAttributeMaskTransparencyColor            \
  368.     (1 << (kQ3AttributeTypeTransparencyColor - 1))
  369.  
  370. #define kQ3XAttributeMaskSurfaceTangent                \
  371.     (1 << (kQ3AttributeTypeSurfaceTangent - 1))
  372.  
  373. #define kQ3XAttributeMaskHighlightState                \
  374.     (1 << (kQ3AttributeTypeHighlightState - 1))
  375.  
  376. #define kQ3XAttributeMaskSurfaceShader                \
  377.     (1 << (kQ3AttributeTypeSurfaceShader - 1))
  378.  
  379. #define kQ3XAttributeMaskCustomAttribute            0x80000000
  380.  
  381. #define kQ3XAttributeMaskAll                        \
  382.     (                                                 \
  383.         kQ3XAttributeMaskSurfaceUV             |         \
  384.         kQ3XAttributeMaskShadingUV             |         \
  385.         kQ3XAttributeMaskNormal             |         \
  386.         kQ3XAttributeMaskAmbientCoefficient |         \
  387.         kQ3XAttributeMaskDiffuseColor         |         \
  388.         kQ3XAttributeMaskSpecularColor         |         \
  389.         kQ3XAttributeMaskSpecularControl     |         \
  390.         kQ3XAttributeMaskTransparencyColor     |         \
  391.         kQ3XAttributeMaskSurfaceTangent     |         \
  392.         kQ3XAttributeMaskHighlightState        |        \
  393.         kQ3XAttributeMaskSurfaceShader        |        \
  394.         kQ3XAttributeMaskCustomAttribute            \
  395.     )
  396.  
  397. #define kQ3XAttributeMaskInherited                    \
  398.     (                                                 \
  399.         kQ3XAttributeMaskSurfaceUV             |         \
  400.         kQ3XAttributeMaskShadingUV             |         \
  401.         kQ3XAttributeMaskNormal             |         \
  402.         kQ3XAttributeMaskAmbientCoefficient |        \
  403.         kQ3XAttributeMaskDiffuseColor         |         \
  404.         kQ3XAttributeMaskSpecularColor         |         \
  405.         kQ3XAttributeMaskSpecularControl     |         \
  406.         kQ3XAttributeMaskTransparencyColor     |         \
  407.         kQ3XAttributeMaskSurfaceTangent     |         \
  408.         kQ3XAttributeMaskHighlightState             \
  409.     )
  410.  
  411. #define kQ3XAttributeMaskInterpolated                \
  412.     (                                                 \
  413.         kQ3XAttributeMaskSurfaceUV             |         \
  414.         kQ3XAttributeMaskShadingUV             |         \
  415.         kQ3XAttributeMaskNormal             |         \
  416.         kQ3XAttributeMaskAmbientCoefficient |         \
  417.         kQ3XAttributeMaskDiffuseColor         |         \
  418.         kQ3XAttributeMaskSpecularColor         |         \
  419.         kQ3XAttributeMaskSpecularControl     |         \
  420.         kQ3XAttributeMaskTransparencyColor     |         \
  421.         kQ3XAttributeMaskSurfaceTangent     |         \
  422.     )
  423.  
  424. typedef unsigned long TQ3XAttributeMask;
  425.  
  426. QD3D_EXPORT TQ3XAttributeMask QD3D_CALL Q3XAttributeSet_GetMask(
  427.     TQ3AttributeSet            attributeSet);
  428.  
  429.  
  430. /******************************************************************************
  431.  **                                                                             **
  432.  **                            Renderer Draw Context Tools                         **
  433.  **                                                                             **
  434.  *****************************************************************************/
  435.  
  436. typedef struct TQ3XDrawRegionPrivate    *TQ3XDrawRegion;
  437.  
  438. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetDrawRegion(
  439.     TQ3DrawContextObject    drawContext,
  440.     TQ3XDrawRegion            *drawRegion);
  441.  
  442. typedef enum TQ3XDrawContextValidationMasks {
  443.     kQ3XDrawContextValidationClearFlags            =    0x00000000L,
  444.  
  445.     kQ3XDrawContextValidationDoubleBuffer        =    1 << 0,
  446.     kQ3XDrawContextValidationShader                =    1 << 1,
  447.     kQ3XDrawContextValidationClearFunction        =    1 << 2,
  448.     kQ3XDrawContextValidationActiveBuffer        =    1 << 3,
  449.     kQ3XDrawContextValidationInternalOffScreen    =    1 << 4,
  450.     kQ3XDrawContextValidationPane                =    1 << 5,
  451.     kQ3XDrawContextValidationMask                =    1 << 6,
  452.     kQ3XDrawContextValidationDevice                =    1 << 7,
  453.     kQ3XDrawContextValidationWindow                =    1 << 8,
  454.     kQ3XDrawContextValidationWindowSize            =    1 << 9,
  455.     kQ3XDrawContextValidationWindowClip            =    1 << 10,
  456.     kQ3XDrawContextValidationWindowPosition        =    1 << 11,
  457.     kQ3XDrawContextValidationPlatformAttributes    =    1 << 12,
  458.     kQ3XDrawContextValidationForegroundShader    =    1 << 13,
  459.     kQ3XDrawContextValidationBackgroundShader    =    1 << 14,
  460.     kQ3XDrawContextValidationColorPalette        =    1 << 15,
  461.     kQ3XDrawContextValidationAll                =    ~0
  462. } TQ3XDrawContextValidationMasks;
  463.  
  464. typedef unsigned long TQ3XDrawContextValidation;
  465.  
  466. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_ClearValidationFlags(
  467.     TQ3DrawContextObject        drawContext);
  468.  
  469. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetValidationFlags(
  470.     TQ3DrawContextObject        drawContext,
  471.     TQ3XDrawContextValidation    *validationFlags);
  472.  
  473.  
  474. /******************************************************************************
  475.  **                                                                             **
  476.  **                            Renderer Draw Region Tools                         **
  477.  **                                                                             **
  478.  *****************************************************************************/
  479.  
  480. typedef enum TQ3XDevicePixelType {    /* These do not indicate byte ordering   */
  481.     kQ3XDevicePixelTypeInvalid        = 0, /* Unknown, un-initialized type     */
  482.     kQ3XDevicePixelTypeRGB32        = 1, /* Alpha:8 (ignored), R:8, G:8, B:8 */
  483.     kQ3XDevicePixelTypeARGB32        = 2, /* Alpha:8, R:8, G:8, B:8              */
  484.     kQ3XDevicePixelTypeRGB24        = 3, /* 24 bits/pixel, R:8, G:8, B:8     */
  485.     kQ3XDevicePixelTypeRGB16        = 4, /* Alpha:1 (ignored), R:5, G:5, B:5 */
  486.     kQ3XDevicePixelTypeARGB16        = 5, /* Alpha:1, R:5, G:5, B:5              */
  487.     kQ3XDevicePixelTypeRGB16_565    = 6, /* 16 bits/pixel, R:5, G:6, B:5     */
  488.     kQ3XDevicePixelTypeIndexed8        = 7, /* 8-bit color table index             */
  489.     kQ3XDevicePixelTypeIndexed4        = 8, /* 4-bit color table index             */
  490.     kQ3XDevicePixelTypeIndexed2        = 9, /* 2-bit color table index             */
  491.     kQ3XDevicePixelTypeIndexed1        = 10 /* 1-bit color table index             */
  492. } TQ3XDevicePixelType;
  493.  
  494. typedef enum TQ3XClipMaskState {
  495.     kQ3XClipMaskFullyExposed,
  496.     kQ3XClipMaskPartiallyExposed,
  497.     kQ3XClipMaskNotExposed
  498. } TQ3XClipMaskState;
  499.  
  500. typedef struct TQ3XColorDescriptor {
  501.     unsigned long            redShift;
  502.     unsigned long            redMask;
  503.     unsigned long            greenShift;
  504.     unsigned long            greenMask;
  505.     unsigned long            blueShift;
  506.     unsigned long            blueMask;
  507.     unsigned long            alphaShift;
  508.     unsigned long            alphaMask;
  509. } TQ3XColorDescriptor;
  510.  
  511. typedef struct TQ3XDrawRegionDescriptor {
  512.     unsigned long            width;
  513.     unsigned long            height;
  514.     unsigned long            rowBytes;
  515.     unsigned long            pixelSize;
  516.     TQ3XDevicePixelType        pixelType;
  517.     TQ3XColorDescriptor        colorDescriptor;
  518.     TQ3Endian                bitOrder;
  519.     TQ3Endian                byteOrder;
  520.     TQ3Bitmap                *clipMask;
  521. } TQ3XDrawRegionDescriptor;
  522.  
  523. typedef enum TQ3XDrawRegionServicesMasks {
  524.     kQ3XDrawRegionServicesNoneFlag                =    0L,
  525.     kQ3XDrawRegionServicesClearFlag                =    1 << 0,
  526.     kQ3XDrawRegionServicesDontLockDDSurfaceFlag    =    1 << 1
  527. } TQ3XDrawRegionServicesMasks;
  528.  
  529. typedef unsigned long TQ3XDrawRegionServices;
  530.  
  531. typedef void (QD3D_CALLBACK *TQ3XDrawRegionRendererPrivateDeleteMethod)(
  532.     void    *rendererPrivate);
  533.  
  534. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceScaleX( 
  535.     TQ3XDrawRegion     drawRegion,
  536.     float            *deviceScaleX);
  537.  
  538. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceScaleY( 
  539.     TQ3XDrawRegion     drawRegion,
  540.     float            *deviceScaleY);
  541.  
  542.  
  543. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceOffsetX( 
  544.     TQ3XDrawRegion     drawRegion,
  545.     float            *deviceOffsetX);
  546.  
  547. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceOffsetY( 
  548.     TQ3XDrawRegion     drawRegion,
  549.     float            *deviceOffsetX);
  550.  
  551.  
  552. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowScaleX( 
  553.     TQ3XDrawRegion     drawRegion,
  554.     float            *windowScaleX);
  555.  
  556. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowScaleY( 
  557.     TQ3XDrawRegion     drawRegion,
  558.     float            *windowScaleY);
  559.  
  560.  
  561. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowOffsetX( 
  562.     TQ3XDrawRegion     drawRegion,
  563.     float            *windowOffsetX);
  564.  
  565. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowOffsetY( 
  566.     TQ3XDrawRegion     drawRegion,
  567.     float            *windowOffsetY);
  568.  
  569. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_IsActive( 
  570.     TQ3XDrawRegion     drawRegion,
  571.     TQ3Boolean        *isActive);
  572.  
  573.  
  574. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetNextRegion( 
  575.     TQ3XDrawRegion     drawRegion,
  576.     TQ3XDrawRegion    *nextDrawRegion);
  577.  
  578. /* 
  579.  *  One of the next two functions must be called before using a draw region 
  580.  */
  581.  
  582. /*
  583.  *    Use this Start function if double buffering/image access services from the
  584.  *    Draw Context are not needed, you may still request clear for example
  585.  */
  586. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_Start( 
  587.     TQ3XDrawRegion                drawRegion, 
  588.     TQ3XDrawRegionServices        services,
  589.     TQ3XDrawRegionDescriptor    **descriptor);
  590.  
  591. /*
  592.  *    Use this Start function if double buffering or image access services from 
  593.  *  the Draw Context are needed.
  594.  */
  595. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_StartAccessToImageBuffer( 
  596.     TQ3XDrawRegion                drawRegion, 
  597.     TQ3XDrawRegionServices        services,
  598.     TQ3XDrawRegionDescriptor    **descriptor,
  599.     void                        **image);
  600.  
  601. /*
  602.  *    This function is used to indicate that access to a DrawRegion is ended.
  603.  */
  604. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_End( 
  605.     TQ3XDrawRegion         drawRegion);
  606.  
  607. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceTransform( 
  608.     TQ3XDrawRegion         drawRegion,
  609.     TQ3Matrix4x4        **deviceTransform);
  610.  
  611. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipFlags( 
  612.     TQ3XDrawRegion         drawRegion,
  613.     TQ3XClipMaskState    *clipMaskState);
  614.     
  615. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipMask( 
  616.     TQ3XDrawRegion         drawRegion,
  617.     TQ3Bitmap            **clipMask);
  618.     
  619. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  620.  
  621. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipRegion(
  622.     TQ3XDrawRegion    drawRegion,
  623.     RgnHandle        *rgnHandle);
  624.     
  625. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetGDHandle(
  626.     TQ3XDrawRegion    drawRegion,
  627.     GDHandle        *gdHandle);
  628.     
  629. #endif  /* WINDOW_SYSTEM_MACINTOSH  */     
  630.  
  631. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetRendererPrivate( 
  632.     TQ3XDrawRegion     drawRegion,
  633.     void            **rendererPrivate);
  634.  
  635. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_SetRendererPrivate( 
  636.     TQ3XDrawRegion                                 drawRegion, 
  637.     const void                                     *rendererPrivate,
  638.     TQ3XDrawRegionRendererPrivateDeleteMethod    deleteMethod);
  639.  
  640. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_SetUseDefaultRendererFlag( 
  641.     TQ3XDrawRegion    drawRegion, 
  642.     TQ3Boolean         flag);
  643.  
  644. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetUseDefaultRendererFlag( 
  645.     TQ3XDrawRegion    drawRegion,
  646.     TQ3Boolean        *useDefaultRenderingFlag);
  647.  
  648.  
  649. /******************************************************************************
  650.  **                                                                             **
  651.  **                            Renderer Class Methods                             **
  652.  **                                                                             **
  653.  *****************************************************************************/
  654. /*
  655.  *    Methods from Object
  656.  *        kQ3XMethodTypeObjectClassRegister
  657.  *        kQ3XMethodTypeObjectClassUnregister
  658.  *        kQ3XMethodTypeObjectNew
  659.  *        kQ3XMethodTypeObjectDelete
  660.  *        kQ3XMethodTypeObjectRead
  661.  *        kQ3XMethodTypeObjectTraverse
  662.  *        kQ3XMethodTypeObjectWrite
  663.  *        
  664.  *    Methods from Shared
  665.  *        kQ3MethodTypeSharedEdited
  666.  *
  667.  *    Renderer Methods
  668.  *    
  669.  *    The renderer methods should be implemented according to the type
  670.  *    of renderer being written.
  671.  *
  672.  *    For the purposes of documentation, there are two basic types of
  673.  *    renderers: 
  674.  *
  675.  *        Interactive
  676.  *            Interactive Renderer
  677.  *            WireFrame Renderer
  678.  *        
  679.  *        Deferred
  680.  *            a ray-tracer
  681.  *            painter's algorithm renderer (cached in a BSP triangle tree)
  682.  *            an artistic renderer (simulates a pencil drawing, etc.)
  683.  *
  684.  *    The main difference is how each renderer handles incoming state and 
  685.  *    geometry.
  686.  *
  687.  *    An interactive renderer immediately transforms, culls, and shades
  688.  *    incoming geometry and performs rasterization. For example, in a 
  689.  *    single-buffered WireFrame renderer, you will see a new triangle
  690.  *    immediately after Q3Triangle_Draw (if it's visible, of course).
  691.  *
  692.  *    A deferred renderer caches the view state and each geometry, 
  693.  *    converting into any internal queue of drawing commands. Rasterization
  694.  *    is not actually performed until all data has been submitted.
  695.  *    
  696.  *    For example, a ray-tracer may not rasterize anything until the
  697.  *    end of the rendering loop, or until an EndFrame call is made.
  698.  */
  699.  
  700.     
  701. /******************************************************************************
  702.  **                                                                             **
  703.  **                        Renderer User Interface Methods                         **
  704.  **                                                                             **
  705.  *****************************************************************************/
  706.  
  707. /*
  708.  *    TQ3XRendererModalConfigureMethod
  709.  *    
  710.  *    This method should pop up a modal dialog to edit the renderer settings 
  711.  *    found in the renderer private. 
  712.  *    
  713.  *    dialogAnchor - is platform specific data passed by the client to support
  714.  *      movable modal dialogs. 
  715.  *    MacOS: this is a callback to the calling application's event handler.
  716.  *      The renderer calls this function with events not handled by the 
  717.  *      settings dialog. This is necessary in order to support movable modal 
  718.  *      dialogs. An application's event handler must return kQ3True if it 
  719.  *      handles the event passed to the callback or kQ3False if not. 
  720.  *      An application which doesn't want to support a movable modal configure
  721.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  722.  *      A renderer should implement a non-movable style dialog in that case.
  723.  *    Win32: this is the HWND of the owning window (typically an application's
  724.  *      main window).  (Win32 application modal dialogs are always movable.)
  725.  *  canceled - returns a boolean inditacating that the user canceled the 
  726.  *    dialog.
  727.  *    
  728.  *    OPTIONAL
  729.  */
  730. #define kQ3XMethodTypeRendererModalConfigure \
  731.     Q3_METHOD_TYPE('r','d','m','c')    
  732. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererModalConfigureMethod)(
  733.     TQ3RendererObject            renderer,
  734.     TQ3DialogAnchor             dialogAnchor, 
  735.     TQ3Boolean                    *canceled,    
  736.     void                        *rendererPrivate);
  737.  
  738. /*
  739.  *    kQ3XMethodTypeRendererGetConfigurationData
  740.  *    
  741.  *        Allows an application to collect private configuration data from the
  742.  *      renderer which it will then save. For example in a preference file, 
  743.  *      a registry key (on Windows) or in a style template. An application 
  744.  *      should tag this data with the renderer's object name.
  745.  *    
  746.  *        If dataBuffer is NULL actualDataSize returns the required size in 
  747.  *        bytes of a data buffer large enough to store private data. 
  748.  *
  749.  *      bufferSize is the actual size of the memory block pointed to by 
  750.  *        dataBuffer
  751.  *
  752.  *        actualDataSize - on return the actual number of bytes written to the
  753.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  754.  *
  755.  *    OPTIONAL
  756.  */
  757. #define kQ3XMethodTypeRendererGetConfigurationData \
  758.     Q3_METHOD_TYPE('r','d','g','p')    
  759. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererGetConfigurationDataMethod)(
  760.     TQ3RendererObject            renderer, 
  761.     unsigned char                *dataBuffer, 
  762.     unsigned long                bufferSize,
  763.     unsigned long                *actualDataSize,    
  764.     void                        *rendererPrivate);
  765.  
  766. /*
  767.  *    TQ3XRendererSetConfigurationDataMethod
  768.  *    
  769.  *        Allows an application to pass private configuration data which has
  770.  *         previously  been obtained from a renderer via 
  771.  *        Q3Renderer_GetConfigurationData. For example in a preference file or 
  772.  *        in a style template. An application should tag this data with the 
  773.  *        renderer's object name.
  774.  *    
  775.  *      bufferSize is the actual size of the memory block pointed to by 
  776.  *        dataBuffer
  777.  *
  778.  *    OPTIONAL
  779.  */
  780. #define kQ3XMethodTypeRendererSetConfigurationData \
  781.     Q3_METHOD_TYPE('r','d','s','p')    
  782. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSetConfigurationDataMethod)(
  783.     TQ3RendererObject            renderer, 
  784.     unsigned char                *dataBuffer, 
  785.     unsigned long                bufferSize,    
  786.     void                        *rendererPrivate);
  787.  
  788. /******************************************************************************
  789.  **                                                                             **
  790.  **                        Renderer Drawing State Methods                         **
  791.  **                                                                             **
  792.  *****************************************************************************/
  793. /*
  794.  *    TQ3RendererStartFrame
  795.  *    
  796.  *    The StartFrame method is called first at Q3View_StartRendering
  797.  *    and should:
  798.  *        - initialize any renderer state to defaults
  799.  *        - extract any and all useful data from the drawContext
  800.  *
  801.  *    If your renderer passed in kQ3RendererFlagClearBuffer at 
  802.  *    registration, then it should also:
  803.  *        - clear the drawContext 
  804.  *    
  805.  *        When clearing, your renderer may opt to:
  806.  *        - NOT clear anything (if you touch every pixel, for example)
  807.  *        - to clear with your own routine, or
  808.  *        - to use the draw context default clear method by calling 
  809.  *        Q3DrawContext_Clear. Q3DrawContext_Clear takes advantage of
  810.  *        any available hardware in the system for clearing.
  811.  *    
  812.  *    This call also signals the start of all default submit commands from
  813.  *    the view. The renderer will receive updates for the default view
  814.  *    state via its Update methods before StartPass is called.
  815.  *    
  816.  *    REQUIRED
  817.  */
  818. #define kQ3XMethodTypeRendererStartFrame    \
  819.     Q3_METHOD_TYPE('r','d','c','l')
  820. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererStartFrameMethod)(
  821.     TQ3ViewObject            view,
  822.     void                    *rendererPrivate,
  823.     TQ3DrawContextObject    drawContext);
  824.     
  825. /*
  826.  *    kQ3XMethodTypeRendererStartPass
  827.  *    TQ3XRendererStartPassMethod
  828.  *    
  829.  *    The StartPass method is called during Q3View_StartRendering but after
  830.  *    the StartFrame command. It should:
  831.  *        - collect camera and light information
  832.  *    
  833.  *    If your renderer supports deferred camera transformation, camera is the
  834.  *    main camera which will be submitted in the hierarchy somewhere. It
  835.  *    is never NULL.
  836.  *
  837.  *    If your renderer does not support deferred camera transformation, camera
  838.  *    is the transformed camera.
  839.  *
  840.  *    If your renderer supports deferred light transformation, lights will be
  841.  *    NULL, and will be submitted to your light draw methods instead.
  842.  *
  843.  *    This call signals the end of the default update state, and the start of 
  844.  *  submit commands from the user to the view.
  845.  *
  846.  *    REQUIRED
  847.  */
  848. #define kQ3XMethodTypeRendererStartPass \
  849.     Q3_METHOD_TYPE('r','d','s','t')
  850. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererStartPassMethod)(
  851.     TQ3ViewObject            view,
  852.     void                    *rendererPrivate,
  853.     TQ3CameraObject            camera,
  854.     TQ3GroupObject            lightGroup);
  855.  
  856. /*
  857.  *    kQ3XMethodTypeRendererFlushFrame
  858.  *    TQ3XRendererFlushFrameMethod
  859.  *    
  860.  *    This call is only implemented by asynchronous renderers.
  861.  *    
  862.  *    The FlushFrame method is called between the StartPass and EndPass
  863.  *    methods and is called when the user wishes to flush any asynchronous
  864.  *    drawing tasks (which draw to the drawcontext), but does not want 
  865.  *    to block.
  866.  *    
  867.  *    The result of this call is that an image should "eventually" appear
  868.  *    asynchronously.
  869.  *    
  870.  *    For asynchronous rendering, this call is non-blocking.
  871.  *    
  872.  *    An interactive renderer should ensure that all received
  873.  *    geometries are drawn in the image.
  874.  *    
  875.  *    An interactive renderer that talks to hardware should force
  876.  *    the hardware to generate an image.
  877.  *    
  878.  *    A deferred renderer should exhibit a similar behaviour,
  879.  *    though it is not required.  A deferred renderer should spawn
  880.  *    a process that generates a partial image from the currently
  881.  *    accumulated drawing state. 
  882.  *    
  883.  *    However, for renderers such as ray-tracers which generally are
  884.  *    quite compute-intensive, FlushFrame is not required and is a no-op.
  885.  *
  886.  *    OPTIONAL
  887.  */
  888. #define kQ3XMethodTypeRendererFlushFrame    \
  889.     Q3_METHOD_TYPE('r','d','f','l')
  890. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererFlushFrameMethod)(
  891.     TQ3ViewObject            view,
  892.     void                    *rendererPrivate,
  893.     TQ3DrawContextObject    drawContext);
  894.  
  895. /*
  896.  *    kQ3XMethodTypeRendererEndPass
  897.  *    TQ3XRendererEndPassMethod
  898.  *    
  899.  *    The EndPass method is called at Q3View_EndRendering and signals
  900.  *    the end of submit commands to the view.
  901.  *
  902.  *    If an error occurs, the renderer should call Q3XError_Post and
  903.  *    return kQ3ViewStatusError.
  904.  *    
  905.  *    If a renderer requires another pass on the renderering data,
  906.  *    it should return kQ3ViewStatusRetraverse.
  907.  *    
  908.  *    If rendering was cancelled, this function will not be called
  909.  *    and the view will handle returning kQ3ViewStatusCancelled;
  910.  *    
  911.  *    Otherwise, your renderer should begin completing the process of 
  912.  *    generating the image in the drawcontext. If you have buffered
  913.  *    any drawing data, flush it. RendererEnd should have a similar
  914.  *    effect as RendererFlushFrame.
  915.  *    
  916.  *    If the renderer is synchronous:
  917.  *        - complete rendering of the entire frame
  918.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer
  919.  *            - Update the front buffer
  920.  *        else
  921.  *            - DrawContext will update the front buffer after returning
  922.  *
  923.  *    If the renderer is asynchronous
  924.  *        - spawn rendering thread for entire frame
  925.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer,
  926.  *            - you must eventually update the front buffer asynchronously
  927.  *        else
  928.  *            - you must eventually update the back buffer asynchronously
  929.  *            
  930.  *    REQUIRED
  931.  */
  932. #define kQ3XMethodTypeRendererEndPass    \
  933.     Q3_METHOD_TYPE('r','d','e','d')
  934. typedef TQ3ViewStatus (QD3D_CALLBACK *TQ3XRendererEndPassMethod)(
  935.     TQ3ViewObject            view,
  936.     void                    *rendererPrivate);
  937.  
  938. /*
  939.  *    kQ3XMethodTypeRendererEndFrame
  940.  *    TQ3XRendererEndFrame
  941.  *    
  942.  *    This call is only implemented by asynchronous renderers.
  943.  *
  944.  *    The EndFrame method is called from Q3View_Sync, which is
  945.  *    called after Q3View_EndRendering and signals that the user
  946.  *    wishes to see the completed image and is willing to block.
  947.  *    
  948.  *    If your renderer supports kQ3RendererFlagDoubleBuffer
  949.  *        - update the front buffer completely 
  950.  *    else
  951.  *        - update the back buffer completely
  952.  *
  953.  *    This call is equivalent in functionality to RendererFlushFrame
  954.  *    but blocks until the image is completed.
  955.  *    
  956.  *    If no method is supplied, the default is a no-op.
  957.  *    
  958.  *    NOTE: Registering a method of this type indicates that your renderer will
  959.  *    be rendering after Q3View_EndRendering has been called.
  960.  *    
  961.  *    OPTIONAL
  962.  */
  963. #define kQ3XMethodTypeRendererEndFrame    \
  964.     Q3_METHOD_TYPE('r','d','s','y')
  965. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererEndFrameMethod)(
  966.     TQ3ViewObject            view,
  967.     void                    *rendererPrivate,
  968.     TQ3DrawContextObject    drawContext);
  969.     
  970. /*
  971.  *    The RendererCancel method is called after Q3View_StartRendering
  972.  *    and signals the termination of all rendering operations.
  973.  *
  974.  *    A renderer should clean up any cached data, and cancel all 
  975.  *    rendering operations.
  976.  *    
  977.  *    If called before Q3View_EndRendering, the RendererEnd method
  978.  *    is NOT called.
  979.  *    
  980.  *    If called after Q3View_EndRendering, the renderer should kill
  981.  *    any threads and terminate any further rendering.
  982.  *    
  983.  *    REQUIRED
  984.  */
  985. #define kQ3XMethodTypeRendererCancel    \
  986.     Q3_METHOD_TYPE('r','d','a','b')
  987. typedef void (QD3D_CALLBACK *TQ3XRendererCancelMethod)(
  988.     TQ3ViewObject            view,
  989.     void                    *rendererPrivate);
  990.  
  991.  
  992. /******************************************************************************
  993.  **                                                                             **
  994.  **                        Renderer DrawContext Methods                         **
  995.  **                                                                             **
  996.  *****************************************************************************/
  997.  
  998. /*
  999.  *    kQ3XMethodTypeRendererPush
  1000.  *    TQ3XRendererPushMethod
  1001.  *    
  1002.  *    kQ3XMethodTypeRendererPop
  1003.  *    TQ3XRendererPopMethod
  1004.  *    
  1005.  *    These methods are called whenever the graphics state in the view
  1006.  *    is pushed or popped. The user may isolate state by calling:
  1007.  *    
  1008.  *    Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &red, view);
  1009.  *    Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &blue, view);
  1010.  *    Q3Attribute_Submit(kQ3AttributeTypeSpecularColor, &white, view);
  1011.  *    Q3Box_Submit(&unitBox, view);
  1012.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1013.  *    Q3Push_Submit(view);
  1014.  *        Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &blue, view);
  1015.  *        Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &green, view);
  1016.  *        Q3Box_Submit(&unitBox, view);
  1017.  *    Q3Pop_Submit(view);    
  1018.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1019.  *    Q3Box_Submit(&unitBox, view);
  1020.  *    
  1021.  *    or by submitting a display group which pushes and pops.
  1022.  *    
  1023.  *    If you support RendererPush and RendererPop in your renderer:
  1024.  *        - you must maintain your drawing state as a stack, as well.
  1025.  *        - you will not be updated with the popped state after
  1026.  *            RendererPop is called.
  1027.  *
  1028.  *    If you do not support Push and Pop in your renderer:
  1029.  *        - you may maintain a single copy of the drawing state.
  1030.  *        - you will be updated with changed fields after the view stack is
  1031.  *            popped.
  1032.  *
  1033.  *    A renderer that supports Push and Pop gets called in the following
  1034.  *    sequence (from example above):
  1035.  *    
  1036.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1037.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1038.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1039.  *    RendererUpdateMatrixLocalToWorld(...)
  1040.  *    RendererSubmitGeometryBox(...)
  1041.  *    RendererPush(...)
  1042.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1043.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1044.  *        RendererSubmitGeometryBox(...)
  1045.  *    RendererPop(...)
  1046.  *    RendererUpdateMatrixLocalToWorld(...)
  1047.  *    RendererSubmitGeometryBox(...)
  1048.  *
  1049.  *    A renderer that does not supports Push and Pop gets called in the
  1050.  *    following sequence:
  1051.  *    
  1052.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1053.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1054.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1055.  *    RendererUpdateMatrixLocalToWorld(...)
  1056.  *    RendererSubmitGeometryBox(...)
  1057.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1058.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1059.  *        RendererSubmitGeometryBox(...)
  1060.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1061.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1062.  *    RendererUpdateMatrixLocalToWorld(...)
  1063.  *    RendererSubmitGeometryBox(...)
  1064.  *    
  1065.  */
  1066. #define kQ3XMethodTypeRendererPush    \
  1067.     Q3_METHOD_TYPE('r','d','p','s')
  1068. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererPushMethod)(
  1069.     TQ3ViewObject            view,
  1070.     void                    *rendererPrivate);
  1071.  
  1072. #define kQ3XMethodTypeRendererPop    \
  1073.     Q3_METHOD_TYPE('r','d','p','o')
  1074. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererPopMethod)(
  1075.     TQ3ViewObject            view,
  1076.     void                    *rendererPrivate);
  1077.  
  1078.  
  1079. /******************************************************************************
  1080.  **                                                                             **
  1081.  **                            Renderer Cull Methods                             **
  1082.  **                                                                             **
  1083.  *****************************************************************************/
  1084. /*
  1085.  *    kQ3XMethodTypeRendererIsBoundingBoxVisible
  1086.  *    TQ3XRendererIsBoundingBoxVisibleMethod
  1087.  *    
  1088.  *    This method is called to cull complex groups and geometries 
  1089.  *    given their bounding box in local space.
  1090.  *    
  1091.  *    It should transform the local-space bounding box coordinates to
  1092.  *    frustum space and return a TQ3Boolean return value indicating
  1093.  *    whether the box appears within the viewing frustum.
  1094.  *    
  1095.  *    If no method is supplied, the default behvaiour is to return
  1096.  *    kQ3True.
  1097.  *    
  1098.  *    TODO: Default to cull to { (-1,1), (-1,1), (0,1) } frustum?
  1099.  */
  1100. #define kQ3XMethodTypeRendererIsBoundingBoxVisible    \
  1101.     Q3_METHOD_TYPE('r','d','b','x')
  1102. typedef TQ3Boolean (QD3D_CALLBACK *TQ3XRendererIsBoundingBoxVisibleMethod)(
  1103.     TQ3ViewObject            view,
  1104.     void                    *rendererPrivate,
  1105.     const TQ3BoundingBox    *bBox);
  1106.  
  1107. /******************************************************************************
  1108.  **                                                                             **
  1109.  **                        Renderer Object Support Methods                         **
  1110.  **                                                                             **
  1111.  *****************************************************************************/
  1112.  
  1113. /*
  1114.  *    Drawing methods (Geometry, Camera, Lights)
  1115.  *
  1116.  */
  1117.  
  1118. /*
  1119.  *    Geometry MetaHandler
  1120.  *    
  1121.  *    This metaHandler is required to support 
  1122.  *    
  1123.  *    kQ3GeometryTypeTriangle
  1124.  *    kQ3GeometryTypeLine
  1125.  *    kQ3GeometryTypePoint
  1126.  *    kQ3GeometryTypeMarker
  1127.  *    kQ3GeometryTypePixmapMarker
  1128.  *    
  1129.  *    REQUIRED
  1130.  */
  1131. #define kQ3XMethodTypeRendererSubmitGeometryMetaHandler    \
  1132.     Q3_METHOD_TYPE('r','d','g','m')
  1133. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitGeometryMetaHandlerMethod)(
  1134.     TQ3ObjectType                    geometryType);
  1135. /*
  1136.  *    The TQ3XRendererSubmitGeometryMetaHandlerMethod switches on geometryType
  1137.  *    of kQ3GeometryTypeFoo and returns methods of type:
  1138.  */
  1139. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitGeometryMethod)(
  1140.     TQ3ViewObject                    view,
  1141.     void                            *rendererPrivate,
  1142.     TQ3GeometryObject                geometry,
  1143.     const void                        *publicData);
  1144.  
  1145.  
  1146. /*
  1147.  *    Camera MetaHandler
  1148.  *    
  1149.  *    This metaHandler, if supplied, indicates that your renderer
  1150.  *    handles deferred transformation of the main camera within a scene.
  1151.  *    
  1152.  *    If not supplied, or an unsupported camera is used, the view will do
  1153.  *    the transformation for the renderer and pass in a camera in the 
  1154.  *    StartPass method.
  1155.  *    
  1156.  *    OPTIONAL
  1157.  */
  1158. #define kQ3XMethodTypeRendererSubmitCameraMetaHandler    \
  1159.     Q3_METHOD_TYPE('r','d','c','m')
  1160. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitCameraMetaHandlerMethod)(
  1161.     TQ3ObjectType                    cameraType);
  1162. /*
  1163.  *    The TQ3XRendererSubmitCameraMetaHandlerMethod switches on cameraType
  1164.  *    of kQ3CameraTypeFoo and returns methods of type:
  1165.  */
  1166. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitCameraMethod)(
  1167.     TQ3ViewObject                    view,
  1168.     void                            *rendererPrivate,
  1169.     TQ3CameraObject                    camera,
  1170.     const void                        *publicData);
  1171.  
  1172.  
  1173. /*
  1174.  *    Light MetaHandler
  1175.  *    
  1176.  *    This metaHandler, if supplied, indicates that your renderer
  1177.  *    handles deferred transformation of lights within a scene.
  1178.  *    
  1179.  *    If an unsupported light is encountered, it is ignored.
  1180.  *
  1181.  *    OPTIONAL
  1182.  */
  1183. #define kQ3XMethodTypeRendererSubmitLightMetaHandler    \
  1184.     Q3_METHOD_TYPE('r','d','l','g')
  1185. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitLightMetaHandlerMethod)(
  1186.     TQ3ObjectType                    lightType);
  1187. /*
  1188.  *    The TQ3XRendererSubmitLightMetaHandlerMethod switches on lightType
  1189.  *    of kQ3LightTypeFoo and returns methods of type:
  1190.  */
  1191. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitLightMethod)(
  1192.     TQ3ViewObject                    view,
  1193.     void                            *rendererPrivate,
  1194.     TQ3LightObject                    light,
  1195.     const void                        *publicData);
  1196.  
  1197. /*
  1198.  *
  1199.  *    Update methods
  1200.  *
  1201.  *    They are called whenever the state has changed. If the renderer supports
  1202.  *    the RendererPush and RendererPop methods, it must maintain its own state
  1203.  *    stack. Updates are not called for changed data when the view stack is
  1204.  *    popped.
  1205.  *
  1206.  *    See the comments for the RendererPush and RendererPop methods above
  1207.  *    for an example of how data is updated.
  1208.  *
  1209.  */
  1210.  
  1211. /*
  1212.  *    Style
  1213.  */
  1214. #define kQ3XMethodTypeRendererUpdateStyleMetaHandler        \
  1215.     Q3_METHOD_TYPE('r','d','y','u')
  1216. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateStyleMetaHandlerMethod)(
  1217.     TQ3ObjectType                    styleType);
  1218. /*
  1219.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on styleType
  1220.  *    of kQ3StyleTypeFoo and returns methods of type:
  1221.  */
  1222. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateStyleMethod)(
  1223.     TQ3ViewObject                    view,
  1224.     void                            *rendererPrivate,
  1225.     const void                        *publicData);
  1226.  
  1227. /*
  1228.  *    Attributes
  1229.  */
  1230. #define kQ3XMethodTypeRendererUpdateAttributeMetaHandler    \
  1231.     Q3_METHOD_TYPE('r','d','a','u')
  1232. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateAttributeMetaHandlerMethod)(
  1233.     TQ3AttributeType                attributeType);
  1234. /*
  1235.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on attributeType
  1236.  *    of kQ3AttributeTypeFoo and returns methods of type:
  1237.  */
  1238. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateAttributeMethod)(
  1239.     TQ3ViewObject                    view,
  1240.     void                            *rendererPrivate,
  1241.     const void                        *publicData);
  1242.  
  1243. /*
  1244.  *    Shaders
  1245.  */
  1246. #define kQ3XMethodTypeRendererUpdateShaderMetaHandler    \
  1247.     Q3_METHOD_TYPE('r','d','s','u')
  1248. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateShaderMetaHandlerMethod)(
  1249.     TQ3ObjectType                    shaderType);
  1250.     
  1251. /*
  1252.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on shaderType
  1253.  *    of kQ3ShaderTypeFoo and returns methods of type:
  1254.  */
  1255. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateShaderMethod)(
  1256.     TQ3ViewObject                    view,
  1257.     void                            *rendererPrivate,
  1258.     TQ3Object                        shaderObject);
  1259.  
  1260. /*
  1261.  *    Matrices
  1262.  */
  1263. #define kQ3XMethodTypeRendererUpdateMatrixMetaHandler                    \
  1264.     Q3_METHOD_TYPE('r','d','x','u')
  1265. typedef TQ3XMetaHandler TQ3XRendererUpdateMatrixMetaHandlerMethod;
  1266.  
  1267. /*
  1268.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on methods
  1269.  *    of the form kQ3MethodTypeRendererUpdateMatrixFoo:
  1270.  */
  1271. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorld                    \
  1272.     Q3_METHOD_TYPE('u','l','w','x')
  1273. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverse            \
  1274.     Q3_METHOD_TYPE('u','l','w','i')
  1275. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverseTranspose    \
  1276.     Q3_METHOD_TYPE('u','l','w','t')
  1277. #define kQ3XMethodTypeRendererUpdateMatrixLocalToCamera                    \
  1278.     Q3_METHOD_TYPE('u','l','c','x')
  1279. #define kQ3XMethodTypeRendererUpdateMatrixLocalToFrustum                \
  1280.     Q3_METHOD_TYPE('u','l','f','x')
  1281. #define kQ3XMethodTypeRendererUpdateMatrixWorldToFrustum                \
  1282.     Q3_METHOD_TYPE('u','w','f','x')
  1283.  
  1284. /*
  1285.  *    and returns methods of type:
  1286.  */
  1287. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateMatrixMethod)(
  1288.     TQ3ViewObject                    view,
  1289.     void                            *rendererPrivate,
  1290.     const TQ3Matrix4x4                *matrix);
  1291.  
  1292. #ifdef __cplusplus
  1293. }
  1294. #endif    /* __cplusplus */
  1295.  
  1296. #if defined(THINK_C) || defined(__SC__)
  1297.     #pragma SC options align=reset
  1298. #elif defined(__MWERKS__)
  1299.     #pragma enumsalwaysint reset
  1300.     #pragma align_array_members reset
  1301.     #pragma options align=reset
  1302. #elif  defined(__PPCC__)
  1303.     #pragma options align=reset
  1304. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  1305.     #pragma options enum=reset
  1306. #endif
  1307.  
  1308. #endif  /*  QD3DRenderer_h  */
  1309.